import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path";
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

import define from './src/utils/define';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
      "components": resolve(__dirname, "src/components"),
      "styles": resolve(__dirname, "src/styles"),
      "plugins": resolve(__dirname, "src/plugins"),
      "views": resolve(__dirname, "src/views"),
      "layouts": resolve(__dirname, "src/layouts"),
      "utils": resolve(__dirname, "src/utils"),
      "api": resolve(__dirname, "src/api"),
      "dirs": resolve(__dirname, "src/directives"),
    },
  },
  server: {
    proxy: {
      "/dev": {
        target: define.baseUrl,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dev/, ""),
      },
    },
  },
})
